package com.qc.ayouth.shop.dbs.service.shop.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qc.ayouth.shop.dbs.constants.DbConstants;
import com.qc.ayouth.shop.dbs.entity.TShopCategory;
import com.qc.ayouth.shop.dbs.mapper.TShopCategoryMapper;
import com.qc.ayouth.shop.dbs.service.shop.TShopCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 类目表  服务实现类
 * </p>
 *
 * @author Haojg
 * @since 2020-07-09
 */
@Service
public class TShopCategoryServiceImpl extends ServiceImpl<TShopCategoryMapper, TShopCategory> implements TShopCategoryService {
    @Override
    public List<TShopCategory> getCategoryMain() {
        QueryWrapper<TShopCategory> qw = new QueryWrapper<>();
        qw.eq("is_deleted", DbConstants.IS_DELETED_NONE);
        qw.eq("pid", 0);
        qw.orderByAsc("sort_order");
        return this.baseMapper.selectList(qw);
    }

    @Override
    public List<TShopCategory> getCategoryChildren(Long catId) {
        QueryWrapper<TShopCategory> qw = new QueryWrapper<>();
        qw.eq("is_deleted", DbConstants.IS_DELETED_NONE);
        qw.eq("pid", catId);
        qw.orderByAsc("sort_order");
        return this.baseMapper.selectList(qw);
    }
}
